package de.koller.faculae.render;

import de.koller.faculae.FNode;
import de.koller.oceanFramework.math.RVec2;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;

public class FCamera extends FNode {
	
	private AffineTransform backupTransform;
	public final RVec2 position = new RVec2();
	public final float scale = 1;
	
	public void transpose( Graphics2D g ) {
		backupTransform = g.getTransform();
		g.setTransform( createTransform() );
	}
	
	public AffineTransform createTransform() {
		AffineTransform a = new AffineTransform();
		a.translate( froot.display.width / 2, froot.display.height / 2 );
		a.scale( scale, scale );
		a.translate( position.x, position.y );
		return a;
	}
	
	public void restore( Graphics2D g ) {
		g.setTransform( backupTransform );
	}
	
}
